package common

import (
	"crypto/sha1"
	"crypto/sha256"
	"encoding/hex"
)

/*
 * Sha1加密
 */
func Sha1(data string) string {
	sha1 := sha1.New()
	sha1.Write([]byte(data))
	return hex.EncodeToString(sha1.Sum(nil))
}

/*
 * Sha1加密
 */
func Sha1Bytes(data []byte) string {
	sha1 := sha1.New()
	sha1.Write(data)
	return hex.EncodeToString(sha1.Sum(nil))
}

/*
 * Sha256加密
 */
func Sha256(data string) []byte {
	h := sha256.New()
	h.Write([]byte(data))
	return h.Sum(nil)
}
